<div class="content-section introduction">
    <div class="feature-intro">
        <h1>SplitButton</h1>
        <p>SplitButton groups a set of commands in an overlay with a default command.</p>
    </div>
</div>

<div class="content-section implementation">
    <p-toast></p-toast>

    <div class="card">
        <h5>Basic</h5>
        <p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('info')" [model]="items"></p-splitButton>
    
        <h5>Severities</h5>
        <p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('info')" [model]="items"></p-splitButton>
        <p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('info')" [model]="items" styleClass="p-button-secondary"></p-splitButton>
        <p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('success')" [model]="items" styleClass="p-button-success"></p-splitButton>
        <p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('info')" [model]="items" styleClass="p-button-info"></p-splitButton>
        <p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('warn')" [model]="items" styleClass="p-button-warning"></p-splitButton>
        <p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('info')" [model]="items" styleClass="p-button-help"></p-splitButton>
        <p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('error')" [model]="items" styleClass="p-button-danger"></p-splitButton>
    </div>
</div>

<div class="content-section documentation">
    <p-tabView>
        <p-tabPanel header="Documentation">
                    <h5>Import</h5>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
import &#123;SplitButtonModule&#125; from 'primeng/splitbutton';
</app-code>

            <h5>Getting Started</h5>
            <p>SplitButton has a default command button and a collection of menuitems to be displayed in an overlay.</p>

<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-splitButton label="Save" icon="pi pi-check" (onClick)="save()" [model]="items"&gt;&lt;/p-splitButton&gt;
</app-code>

            <h5>Animation Configuration</h5>
            <p>Transition of the open and hide animations can be customized using the <i>showTransitionOptions</i> and <i>hideTransitionOptions</i> properties, 
                example below disables the animations altogether.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-splitButton [showTransitionOptions]="'0ms'" [hideTransitionOptions]="'0ms'" label="Save" icon="pi pi-check" (onClick)="save()" [model]="items"&gt;&lt;/p-splitButton&gt;
</app-code>
            <h5>MenuModel API</h5>
            <p>SplitButton uses the common menumodel api to define its items, visit <a [routerLink]="['/menumodel']">MenuModel API</a> for details.</p>

            <h5>Properties</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>label</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Text of the button.</td>
                        </tr>
                        <tr>
                            <td>icon</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Name of the icon.</td>
                        </tr>
                        <tr>
                            <td>iconPos</td>
                            <td>string</td>
                            <td>left</td>
                            <td>Position of the icon, valid values are "left" and "right".</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                        <tr>
                            <td>menuStyle</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the overlay menu.</td>
                        </tr>
                        <tr>
                            <td>menuStyleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the overlay menu.</td>
                        </tr>
                        <tr>
                            <td>appendTo</td>
                            <td>any</td>
                            <td>null</td>
                            <td>Target element to attach the overlay, valid values are "body" or a local ng-template variable of another element (note: use binding with brackets for template variables, e.g. [appendTo]="mydiv" for a div element having #mydiv as variable name).</td>
                        </tr>
                        <tr>
                            <td>disabled</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that the component should be disabled.</td>
                        </tr>
                        <tr>
                            <td>tabindex</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Index of the element in tabbing order.</td>
                        </tr>
                        <tr>
                            <td>dir</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Indicates the direction of the element.</td>
                        </tr>
                        <tr>
                            <td>showTransitionOptions</td>
                            <td>string</td>
                            <td>225ms ease-out</td>
                            <td>Transition options of the show animation.</td>
                        </tr>
                        <tr>
                            <td>hideTransitionOptions</td>
                            <td>string</td>
                            <td>195ms ease-in</td>
                            <td>Transition options of the hide animation.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Events</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onClick</td>
                            <td>event: browser event<br></td>
                            <td>Callback to invoke when default command button is clicked.</td>
                        </tr>
                        <tr>
                            <td>onDropdownClick</td>
                            <td>event: browser event<br></td>
                            <td>Callback to invoke when dropdown button is clicked.</td>
                        </tr>
                    </tbody>
                </table>
            </div>
          <h5>Severity</h5>
          <p>Different color options are available to define severity levels.</p>

          <ul>
            <li>.p-button-secondary</li>
            <li>.p-button-success</li>
            <li>.p-button-info</li>
            <li>.p-button-warning</li>
            <li>.p-button-help</li>
            <li>.p-button-danger</li>
          </ul>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-splitButton label="Save" icon="pi pi-check" [model]="items" styleClass="p-button-warning"&gt;&lt;/p-splitButton&gt;
</app-code>
            <h5>Styling</h5>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>. SplitButton uses
            button and menu components internally, refer to their documentation for the detailed style list.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>p-splitbutton</td>
                            <td>Container element.</td>
                        </tr>
                        <tr>
                            <td>p-splitbutton-button</td>
                            <td>Dropdown button.</td>
                        </tr>
                        <tr>
                            <td>p-menu</td>
                            <td>Overlay menu.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Dependencies</h5>
            <p>None.</p>
        </p-tabPanel>
        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/splitbutton" class="btn-viewsource" target="_blank">
                <span>View on GitHub</span>
            </a>
            <a href="https://stackblitz.com/edit/primeng-splitbutton-demo" class="btn-viewsource" style="margin-left: .5em;" target="_blank">
                <span>Edit in StackBlitz</span>
            </a>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-toast [style]="&#123;marginTop: '80px'&#125;"&gt;&lt;/p-toast&gt;

&lt;h5&gt;Basic&lt;/h5&gt;
&lt;p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('info')" [model]="items"&gt;&lt;/p-splitButton&gt;

&lt;h5&gt;Severities&lt;/h5&gt;
&lt;p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('info')" [model]="items" styleClass="p-button-secondary"&gt;&lt;/p-splitButton&gt;
&lt;p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('success')" [model]="items" styleClass="p-button-success"&gt;&lt;/p-splitButton&gt;
&lt;p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('info')" [model]="items" styleClass="p-button-info"&gt;&lt;/p-splitButton&gt;
&lt;p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('warn')" [model]="items" styleClass="p-button-warning"&gt;&lt;/p-splitButton&gt;
&lt;p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('warn')" [model]="items" styleClass="p-button-help"&gt;&lt;/p-splitButton&gt;
&lt;p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('error')" [model]="items" styleClass="p-button-danger"&gt;&lt;/p-splitButton&gt;
</app-code>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class SplitButtonDemo implements OnInit &#123;

    items: MenuItem[];

    constructor(private messageService: MessageService) &#123;&#125;

    ngOnInit() &#123;
        this.items = [
            &#123;label: 'Update', icon: 'pi pi-refresh', command: () => &#123;
                this.update();
            &#125;&#125;,
            &#123;label: 'Delete', icon: 'pi pi-times', command: () => &#123;
                this.delete();
            &#125;&#125;,
            &#123;label: 'Angular.io', icon: 'pi pi-info', url: 'http://angular.io'&#125;,
            &#123;separator: true&#125;,
            &#123;label: 'Setup', icon: 'pi pi-cog', routerLink: ['/setup']&#125;
        ];
    &#125;

    save(severity: string) &#123;
        this.messageService.add(&#123;severity:severity, summary:'Success', detail:'Data Saved'&#125;);
    &#125;

    update() &#123;
        this.messageService.add(&#123;severity:'success', summary:'Success', detail:'Data Updated'&#125;);
    &#125;

    delete() &#123;
        this.messageService.add(&#123;severity:'success', summary:'Success', detail:'Data Deleted'&#125;);
    &#125;
&#125;
</app-code>
        </p-tabPanel>
        <p-tabPanel header="StackBlitz">
            <ng-template pTemplate="content">
                <iframe src="https://stackblitz.com/edit/primeng-splitbutton-demo?embed=1" style="width: 100%; height: 768px; border: none;"></iframe>
            </ng-template>
        </p-tabPanel>
     </p-tabView >
</div>
